package com.golfwithfriends.controller;

import java.util.List;

import android.util.Log;

import com.golfwithfriends.model.Parcour;
import com.golfwithfriends.model.Player;

public class ParcourController {

	private Parcour parcour;
	private static ParcourController INSTANCE = null;
	
	private ParcourController()
	{
	}
	
	public static ParcourController getInstance()
	{
		if (INSTANCE == null)
			INSTANCE = new ParcourController();
		return INSTANCE;
	}
	
	public void initParcour(int nbTrou, List<String> p)
	{
		this.parcour = new Parcour(nbTrou);
		Log.i("INFO", "Adding new parcour with nbTrous=" + nbTrou);
		String name;
		for (int i = 0; i < p.size(); i++)
		{
			name = p.get(i);
			Player pl = new Player(name, nbTrou);
			parcour.addPlayer(pl);
			Log.i("INFO", "Adding new player with name=" + name);
		}
	}
	
	public int getNbPlayerInGame()
	{
		return parcour.getNbPlayer();
	}
	
	public String getPlayerNameAtIndex(int i)
	{
		return parcour.getPlayerNameAtIndex(i);
	}
	
	public int getCurrentHole()
	{
		return parcour.getCurrentHole();
	}
	
	public int getTotalHoles()
	{
		return parcour.getNbHole();
	}
}
